package org.ourgrid.worker.communication.sender;

import org.ourgrid.common.interfaces.AccountingAggregator;
import org.ourgrid.common.internal.SenderIF;
import org.ourgrid.worker.response.ReportWorkAccountingActionResponseTO;

import br.edu.ufcg.lsd.commune.container.servicemanager.ServiceManager;
import br.edu.ufcg.lsd.commune.identification.DeploymentID;

public class ReportWorkAccoutingActionSender implements SenderIF<ReportWorkAccountingActionResponseTO> {

	public void execute(ReportWorkAccountingActionResponseTO response, ServiceManager manager) {
        DeploymentID deploymentID = new DeploymentID(response.getAccountingAgregatorAddress());
        AccountingAggregator accountingAggregator = (AccountingAggregator) manager.getStub(deploymentID.getServiceID(), AccountingAggregator.class);
        
        accountingAggregator.reportWorkAccounting(response.getWorkAccountings());
	}
}